package com.cysion.study.presenter

import com.cysion.study.ktbox.base.BasePresenter
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.other.addTo
import com.cysion.targetfun._subscribe
import com.cysion.study.net.ApiClient
import com.cysion.study.ui.iview.ProMoneyView

class ProMoneyPresenter : BasePresenter<ProMoneyView>() {
    fun getProMoney(curPage: Int) {
        checkViewAttached()
        ApiClient.api.getBlogList(page = curPage)
            .compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    attchedView?.stopLoad()
                    attchedView?.onProMoney(it)
                }
                _onError {
                    attchedView?.stopLoad()
                    attchedView?.onGetProMoneyError(ErrorHandler.handle(it))
                }
            }.addTo(compositeDisposable)
    }
}